package com.ly.service.impl;

import com.ly.mapper.UserMapper;
import com.ly.pojo.User;
import com.ly.service.UserService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserMapper userMapper;


    public int updateUser(String userid,String newName,String fileId) {
        User user = userMapper.selectById(userid);
        user.setName(newName);
        user.setPortrait(fileId);
        user.setUpdateTime(new Date());
        System.out.println(user);
        int i = userMapper.updateById(user);
        return i;
    }

    @Override
    public int updatePassword(@Param("id") String userid, String password) {
        //根据Id查询到的user
        User user = userMapper.selectById(userid);
        user.setUpdateTime(new Date());
        user.setPassword(password);
        int i = userMapper.updateById(user);
        return i;
    }
}
